﻿using System;
using System.Collections.Generic;
using System.Text;

namespace JCChangeCalculatorControl
{
    class billFactory
    {
        private List<bill> _billList = new List<bill>();
        private List<bill> _standardUSBills = new List<bill>(); 

        public billFactory()
        {
            this.buildStandardBills();
        }

        /// <summary>
        /// Creates a list of bill objects greater than the baseAmount.
        /// </summary>
        /// <value>List</value>
        public List<bill> MakeBills(int qty, decimal baseAmount)
        {
            this._billList.Clear();
            foreach (bill Bill in this._standardUSBills)
            {
                if (Bill.billAmount >= baseAmount)
                {
                    this._billList.Add(Bill);
                }
            }

            // if we produce less bills than requested then we
            // insert empty bills.
            if (this._billList.Count < qty)
            {
                for (int i = 0; i <= (qty - _billList.Count) + 2; i++)
                { 
                    this._billList.Add(new bill(string.Empty,0));
                }
            }
            return this._billList;
        }

        private void buildStandardBills()
        {
            _standardUSBills.Add(new bill("One Dollar Bill", 1));
            _standardUSBills.Add(new bill("Five Dollar Bill", 5));
            _standardUSBills.Add(new bill("Ten Dollar Bill", 10));
            _standardUSBills.Add(new bill("Twenty Dollar Bill", 20));
            _standardUSBills.Add(new bill("Fifty Dollar Bill", 50));
            _standardUSBills.Add(new bill("One Hundred Dollar Bill", 100));
        }
    }

   class bill
    {
        private string _billName;
        private decimal _billAmount;

        public bill(string billName, decimal billAmount)
        {
            this._billAmount = billAmount;
            this._billName = billName;
        }

        /// <summary>
        /// Name of the bill.
        /// </summary>
        /// <value>string</value>
        public string billName
        {
            get { return this._billName; }
        }

        /// <summary>
        /// The amount of the bill.
        /// </summary>
        /// <value>decimal</value>
        public decimal billAmount
        {
            get { return this._billAmount; }
        }

        /// <summary>
        /// String representation of the bill.
        /// </summary>
        /// <returns>string</returns>
        public override string ToString()
        {
            return this._billName;
        }

    }

}
